package com.jerry.alibaba.transaction.controller;

import com.jerry.alibaba.transaction.entity.Account;
import com.jerry.alibaba.transaction.entity.CommonResult;
import com.jerry.alibaba.transaction.entity.Storage;
import com.jerry.alibaba.transaction.service.AccountFeignService;
import com.jerry.alibaba.transaction.service.StorageFeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.math.BigDecimal;

@RestController
@Slf4j
public class AccountController {

    @Resource
    private AccountFeignService accountFeignService;

    @GetMapping("/client/account/create")
    public CommonResult create(Account account) {
        return accountFeignService.create(account);
    }

    @GetMapping("/client/account/get")
    public CommonResult getList() {
        return accountFeignService.getList();
    }

    @GetMapping("/client/account/get/{id}")
    public CommonResult getById(@PathVariable("id") Long id) {
        return accountFeignService.getById(id);
    }

    @GetMapping("/client/account/decrease")
    CommonResult decrease(@RequestParam("userId") Long userId, @RequestParam("money") BigDecimal money){
        return accountFeignService.decrease(userId,money);
    }

}
